const state = {
  cache: new Map()
}
const mutations = {
  GET_CACHE: (state, key) => {
    if (!key) return null
    if (!state.cache.has(key)) return null
    return state.cache.get(key)
  },
  SET_CACHE: (state, { key, value }) => {
    if (key !== null && key !== undefined) state.cache.set(key, value)
  },
  REMOVE_CACHE: (state, key) => {
    if (state.dict.has(key)) state.cache.delete(key)
  },
  CLEAN_CACHE: state => {
    state.cache = new Map()
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
